package com.lili.collection.core.fields.support;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;

public class StringTypeSupport extends TypeSupport<String> {

    @Override
    public String convert(Object value) {

        if (value instanceof String) {
            return (String) value;
        }

        if (value instanceof Map || value instanceof List || value instanceof byte[] || value instanceof FileRef) {
            throw new TypeSupportConversionException(value.getClass().getSimpleName(), value);
        }
        if (value instanceof ZonedDateTime) {
            return Utils.format((ZonedDateTime) value);
        }

        return value.toString();
    }

}
